package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.system.domain.TaskLogFour;
import com.ruoyi.system.mapper.TaskLogThreeMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TaskLogThree;
import com.ruoyi.system.service.ITaskLogThreeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务三日志Controller
 * 
 * @author ruoyi
 * @date 2024-09-18
 */
@RestController
@RequestMapping("/system/three/log")
public class TaskLogThreeController extends BaseController
{
    @Autowired
    private ITaskLogThreeService taskLogThreeService;

    @Autowired
    private TaskLogThreeMapper taskLogThreeMapper;


    /**
     * 查询任务三日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:threeLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(TaskLogThree taskLogThree)
    {
        startPage();
        List<TaskLogThree> list = taskLogThreeService.selectTaskLogThreeList(taskLogThree);
        return getDataTable(list);
    }

    /**
     * 导出任务三日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:threeLog:export')")
    @Log(title = "任务三日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TaskLogThree taskLogThree)
    {
        List<TaskLogThree> list = taskLogThreeService.selectTaskLogThreeList(taskLogThree);
        ExcelUtil<TaskLogThree> util = new ExcelUtil<TaskLogThree>(TaskLogThree.class);
        util.exportExcel(response, list, "任务三日志数据");
    }

    /**
     * 获取任务三日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:threeLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(taskLogThreeService.selectTaskLogThreeById(id));
    }

    /**
     * 新增任务三日志
     */
    @PreAuthorize("@ss.hasPermi('system:threeLog:add')")
    @Log(title = "任务三日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TaskLogThree taskLogThree)
    {
        return toAjax(taskLogThreeService.insertTaskLogThree(taskLogThree));
    }

    /**
     * 修改任务三日志
     */
    @PreAuthorize("@ss.hasPermi('system:threeLog:edit')")
    @Log(title = "任务三日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TaskLogThree taskLogThree)
    {
        return toAjax(taskLogThreeService.updateTaskLogThree(taskLogThree));
    }

    /**
     * 删除任务三日志
     */
    @PreAuthorize("@ss.hasPermi('system:threeLog:remove')")
    @Log(title = "任务三日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(taskLogThreeService.deleteTaskLogThreeByIds(ids));
    }


    /**
     * 查询任务三日志 主任务关联的列表
     */
//    @PreAuthorize("@ss.hasPermi('system:oneLog:list')")
    @PostMapping("/taskLogList")
    public AjaxResult taskLogList(@RequestBody TaskLogThree taskLogThree)
    {
//        QueryWrapper<TaskLogThree> queryWrapper = new QueryWrapper<TaskLogThree>();
//        queryWrapper.select("id","task_id","type","title","content","operator_name","operator_time")
//                .eq("task_id", taskLogThree.getTaskId())
//                .eq("type",0);

        List<TaskLogThree> taskLogThreeList = taskLogThreeMapper.selectTaskLogThreeListByLog(taskLogThree);

        return AjaxResult.success(taskLogThreeList);
    }







}
